package com.msmall.community.admin.action;

import com.msmall.base.action.HTMLBaseAction;
import com.msmall.base.util.ConstantUrl;
import com.msmall.community.common.model.UserAgent;
import com.msmall.community.common.service.UserAgentManager;

public class UserAgentAction  extends HTMLBaseAction {

	private static final long serialVersionUID = 8395050717467271917L;

	private Long agentId;
	
	private String agentIds;
	
	private UserAgent userAgent;
	
	private UserAgentManager userAgentManager;

	public String execute(){
		page.setPageSize(10);
		page.setOrderBy("agentId");
		page.setOrder("desc");
		page.setClazz(UserAgent.class);
		userAgentManager.getPagination(page);
		page.setUrl(ConstantUrl.ADMIN_USERAGENT_INDEX);
		return SUCCESS;
	}
	
	public String create(){
		setUserAgent(null);
		return SUCCESS;
	}
	
	public String update(){
		setUserAgent((UserAgent)userAgentManager.get(UserAgent.class, agentId));
		return SUCCESS;
	}
	
	public String save(){
		if(userAgent.getEnabled() == null){
			userAgent.setEnabled((short)0);
		}
		userAgentManager.saveUserAgent(userAgent);
		return SUCCESS;
	}

	public UserAgent getUserAgent() {
		return userAgent;
	}

	public void setUserAgent(UserAgent userAgent) {
		this.userAgent = userAgent;
	}

	public void setUserAgentManager(UserAgentManager userAgentManager) {
		this.userAgentManager = userAgentManager;
	}

	public Long getAgentId() {
		return agentId;
	}

	public void setAgentId(Long agentId) {
		this.agentId = agentId;
	}

	public String getAgentIds() {
		return agentIds;
	}

	public void setAgentIds(String agentIds) {
		this.agentIds = agentIds;
	}
	
}
